package io.zhifei.modules.sys.system.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.zhifei.common.utils.PageUtils;
import io.zhifei.modules.sys.system.dao.SysRecordingDao;
import io.zhifei.modules.sys.system.entity.SysVideoEntity;
import io.zhifei.modules.sys.system.service.SysRecordingService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @ClassNameSysRecordingImpl
 * @Description
 * @Author
 * @Date2020/11/13 11:43
 * @Version V1.0
 **/
@Service
public class SysRecordingImpl extends ServiceImpl<SysRecordingDao, SysVideoEntity> implements SysRecordingService {

    @Autowired
    private SysRecordingDao sysRecordingDao;

    @Override
    public PageUtils getVideoList(String startTime, String endTime, String createUser,
                                  Integer page, Integer pageSize,Integer phase) {
        if (StringUtils.isEmpty(startTime) || StringUtils.isEmpty(endTime)){
            startTime = null;
            endTime = null;
        }
        Page pageParams = new Page(page, pageSize);
        Page<Map<String, Object>> pageResult = sysRecordingDao.getVideoList(pageParams, startTime, endTime, createUser,phase);
        return new PageUtils(pageResult);
    }

    @Override
    public void deleteVideo(String[] ids) {
        for (String id : ids) {
            SysVideoEntity sysVideoEntity = new SysVideoEntity();
            sysVideoEntity.setId(Long.valueOf(id));
            sysVideoEntity.setFlag(1);
            sysRecordingDao.updateById(sysVideoEntity);
        }
    }
}
